package approve.adapter;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import approve.action.R;
import resource.pojo.Approvedoc;

public class My_App_ApprovedDocument_adapter extends BaseAdapter implements OnClickListener  {

	private Context context;
	private List<Approvedoc> listApprovedoc;
	private String creday,appday;
	
	public My_App_ApprovedDocument_adapter(Context context,List<Approvedoc> listApprovedoc,String creday,String appday ){
		this.context=context;
		this.listApprovedoc=listApprovedoc;
		this.appday=appday;
		this.creday=creday;
	}
	public int getCount() {
		// TODO Auto-generated method stub
		return listApprovedoc.size();
	}

	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return listApprovedoc.get(position);
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		Approvedoc entry=listApprovedoc.get(position);
		if(convertView==null){
			LayoutInflater inflater=(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView=inflater.inflate(R.layout.approve_row, null);
		}
		TextView tvTitleError=(TextView)convertView.findViewById(R.id.titleError);
		tvTitleError.setText(entry.getTitle());

		DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		TextView tvPhone = (TextView) convertView.findViewById(R.id.tvMobile);
        tvPhone.setText(entry.getTypeName());

		TextView tvPhone_ = (TextView) convertView.findViewById(R.id.tvMobile_);
        tvPhone_.setText(creday+": "+format.format(entry.getTimecreate())+" - "+appday+": "+format.format(entry.getTimeApprove()));
		return convertView;
	}

	public void onClick(View v) {
		// TODO Auto-generated method stub
		
	}

}
